import { Jem } from "../../GameFramework/event/Jem";
import { GameDB } from "./GameDB";
import GameEvent from "./GameEvent";
import GameView from "./GameView/GameView";

class GameCtrl{
  private gameView:GameView = null;
  private gameDB:GameDB = null;

  public init(gameView:GameView){
    this.gameView = gameView;
    this.gameDB = new GameDB();
    this.gameDB.on(GameEvent.ININT_POCKER,this.gameView.onEventInit,this.gameView);
    this.gameDB.on(GameEvent.PLAY,this.gameView.onEventPlay,this.gameView);
    this.gameDB.on(GameEvent.INIT_GROUP_CARD,this.gameView.onEventInitGroupCard,this.gameView);
    this.gameDB.init();
  }

  public play(){
    //移动所有牌到发牌区
    this.gameDB.play();
  }

  public exit(){
    this.gameDB.off(GameEvent.ININT_POCKER,this.gameView.onEventInit);
  }
}

export{
  GameCtrl
}